﻿#region
/*******************************************************************************
** File Name:		    IDCreaterRepository.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using EWineShop.Entity;
using EWineShop.Respository;
using IBatisNet.DataMapper;
using EWineShop.Data.IBatis;
using System.Collections;

namespace EWineShop.IBatisRepository
{
    public class IDCreaterRepository : BaseIBatisDao,IIDCreater
    {
    
		#region  Auto Generation

        public IDCreaterRepository()
            : base("/Config/IBatis/EWineShopMap.Config")
        {

        }
        		
        public void AddIDCreater(EIDCreater entity)
        {
			string stmtId = "IDCreaterMap.InsertIDCreater";
			base.SqlMapper.Insert(stmtId, entity);
        }
        
		public  EIDCreater GetByIDName (System.String iDName)
        {
			string stmtId = "IDCreaterMap.SelectByIDName";
			return base.SqlMapper.QueryForObject<EIDCreater>(stmtId, iDName);
        }
        
        public  void DeleteByIDName (System.String iDName)
        {
			string stmtId = "IDCreaterMap.DeleteByIDName";
			base.SqlMapper.Update(stmtId, iDName);
        }
        
        public  void UpdateByIDName (EIDCreater entity)
        {
			string stmtId = "IDCreaterMap.UpdateByIDName";
			base.SqlMapper.Update(stmtId, entity);
        }


		#endregion

        // 生成一个ID
        public int GetNewID(string IDName, string Description, int Seed)
        {
            Hashtable ht = new Hashtable();
            ht.Add("IDName", IDName);
            ht.Add("Description", Description);
            ht.Add("Seed", Seed);
            ht.Add("ReturnID",null);

            base.SqlMapper.Update("IDCreaterMap.GetNewID", ht);

            
            return (int)ht["ReturnID"];
        }
    }
}

